export const flattenRoutes = (routes: any[]) => {
  const result: any[] = []
  routes.forEach((route) => {
    // @ts-ignore
    if (route.meta && Object.hasOwn(route.meta, 'realPath')) {
      route.path = route.meta.realPath
    }
    if (route.children) {
      result.push(route)
      result.push(...flattenRoutes(route.children))
    } else {
      result.push(route)
    }
  })
  return result
}
